<?php
use Yjius\common\Debug;

require __DIR__ . "/../../vendor/autoload.php";

try {
    //例子 -已通
    $config = require dirname(__DIR__) . "/config/open-api/toutiao.php";
    $ser = new \Yjius\openapi\toutiao\TouTiaoOauth($config);
    $res = $ser->getCodeUrl();//回调地址必须是微博方设置的管家的地址，
//    $res2 = $ser->getToken("74751c590490d6dat3BWXuV5RHSNx9C6U53V");
    /*
     *   [data] => Array
                (
                    [access_token] => act.7f8e3af130de2f915348d0a03492a12eZONdvHKx8TlPKaAc0ShVswODkfiH
                    [expires_in] => 48
                    [open_id] => 7016876569692226574
                    [screen_name] => YJius
                    [uid] => 79591844120
                    [uid_type] => 12
                )

            [ret] => 0
     * */
    $res3 = $ser->getUserInfo($res2['data']['access_token'] = 'act.7f8e3af130de2f915348d0a03492a12eZONdvHKx8TlPKaAc0ShVswODkfiH',
        $res2['data']['open_id'] = '7016876569692226574', $res2['data']['screen_name'] = 'YJius');
    /**
     *
     * Array
     * (
     * [age] =>
     * [avatar_url] => https://sf6-cdn-tos.toutiaostatic.com/img/user-avatar/5025f2e83e2459998905cdbbf3d69c54~300x300.image
     * [category] => Array
     * (
     * )
     *
     * [description] => 90后技术宅；苦逼上班族
     * [extra] => Array
     * (
     * )
     *
     * [gender] =>
     * [media_id] => 1693716831644686
     * [media_name] => YJius
     * [open_id] => 7016876569692226574
     * [screen_name] => YJius
     * [uid] => 79591844120
     * [uid_type] => 12
     * [user_verified] =>
     * )
     */

    Debug::print_r($res, $res2, $res3);
    exit;
} catch (Exception $exception) {
    echo $exception->getMessage();
    exit;
}